using System.ComponentModel;

namespace net_work.Common.Utils;

public static class EnumExtensions
{
    public static string? GetDescription(this System.Enum value)
    {
        var field = value.GetType().GetField(value.ToString());
        var attribute =
            field?.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() as DescriptionAttribute;
        return attribute?.Description ?? value.ToString();
    }
}